package com.ruoyi.manager.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.TbeduWeektrack;
import com.ruoyi.manager.service.ITbeduWeektrackService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学员评价Controller
 * 
 * @author superjean
 * @date 2021-08-29
 */
@Controller
@RequestMapping("/manager/weektrack")
public class TbeduWeektrackController extends BaseController
{
    private String prefix = "manager/weektrack";

    @Autowired
    private ITbeduWeektrackService tbeduWeektrackService;

    @RequiresPermissions("manager:weektrack:view")
    @GetMapping()
    public String weektrack()
    {
        return prefix + "/weektrack";
    }

    /**
     * 查询学员评价列表
     */
    @RequiresPermissions("manager:weektrack:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbeduWeektrack tbeduWeektrack)
    {
        startPage();
        List<TbeduWeektrack> list = tbeduWeektrackService.selectTbeduWeektrackList(tbeduWeektrack);
        return getDataTable(list);
    }

    /**
     * 导出学员评价列表
     */
    @RequiresPermissions("manager:weektrack:export")
    @Log(title = "学员评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbeduWeektrack tbeduWeektrack)
    {
        List<TbeduWeektrack> list = tbeduWeektrackService.selectTbeduWeektrackList(tbeduWeektrack);
        ExcelUtil<TbeduWeektrack> util = new ExcelUtil<TbeduWeektrack>(TbeduWeektrack.class);
        return util.exportExcel(list, "学员评价数据");
    }

    /**
     * 新增学员评价
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学员评价
     */
    @RequiresPermissions("manager:weektrack:add")
    @Log(title = "学员评价", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbeduWeektrack tbeduWeektrack)
    {
        return toAjax(tbeduWeektrackService.insertTbeduWeektrack(tbeduWeektrack));
    }

    /**
     * 修改学员评价
     */
    @GetMapping("/edit/{fId}")
    public String edit(@PathVariable("fId") Long fId, ModelMap mmap)
    {
        TbeduWeektrack tbeduWeektrack = tbeduWeektrackService.selectTbeduWeektrackByFId(fId);
        mmap.put("tbeduWeektrack", tbeduWeektrack);
        return prefix + "/edit";
    }

    /**
     * 修改保存学员评价
     */
    @RequiresPermissions("manager:weektrack:edit")
    @Log(title = "学员评价", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbeduWeektrack tbeduWeektrack)
    {
        return toAjax(tbeduWeektrackService.updateTbeduWeektrack(tbeduWeektrack));
    }

    /**
     * 删除学员评价
     */
    @RequiresPermissions("manager:weektrack:remove")
    @Log(title = "学员评价", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbeduWeektrackService.deleteTbeduWeektrackByFIds(ids));
    }
}
